
var $bookmark={
	svcFX3:Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Components.interfaces.nsINavBookmarksService),
	svcFX2:Components.classes["@mozilla.org/browser/bookmarks-service;1"].getService(Components.interfaces.nsIBookmarksService),

	get version(){
		if(Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]){
			return "1.9";
		}
		if(Components.classes["@mozilla.org/browser/bookmarks-service;1"]){
			return "1.8";
		}
		return false
	},
	
	folder:function(title){		
		return this.svc.createFolder(this.svc.bookmarksMenuFolder, title, -1);
	},
	objURI:function(uri){
		return Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI(uri, null, null)
	},
	add:function(title,uri){
//		alert(this.version)
//		if(this.version.match(/^1\.9/)){
	//		this.svc.insertBookmark(this.svc.bookmarksMenuFolder,this.objURI(uri),-1,title)
	//	}else{
	//		this.svcFX2.createBookmarkInContainer(title. uri.toString(), null, title, , null, this.svcFX2.getBookmarksToolbarFolder(), 0)
	//	}
		if(this.version=="1.9"){
			this.svcFX3.insertBookmark(this.svc.bookmarksMenuFolder,this.objURI(uri),-1,title);
			return;
		}
		if(this.version=="1.8"){
			this.svcFX2.createBookmarkInContainer(title, uri.toString(), null, title, null, null, this.svcFX2.getBookmarksToolbarFolder(), 0);
			return;
		}
	
	},
	tag:{
		remove:function(){},
		get:function(){},
		set:function(){},
	}
}

var $bm=$bookmark;